
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/06/2018 13:47:00
-- Generated from EDMX file: E:\MyShare\MyShare\Models\Model.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [bds271453216_db];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[APIInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[APIInfo];
GO
IF OBJECT_ID(N'[dbo].[AppInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AppInfo];
GO
IF OBJECT_ID(N'[dbo].[CommentInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CommentInfo];
GO
IF OBJECT_ID(N'[dbo].[MusicInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MusicInfo];
GO
IF OBJECT_ID(N'[dbo].[NovelInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NovelInfo];
GO
IF OBJECT_ID(N'[dbo].[RecordInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RecordInfo];
GO
IF OBJECT_ID(N'[dbo].[RoleInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RoleInfo];
GO
IF OBJECT_ID(N'[dbo].[StickInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[StickInfo];
GO
IF OBJECT_ID(N'[dbo].[UserInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserInfo];
GO
IF OBJECT_ID(N'[dbo].[VideoInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VideoInfo];
GO
IF OBJECT_ID(N'[dbo].[VideoRecordInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VideoRecordInfo];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'APIInfo'
CREATE TABLE [dbo].[APIInfo] (
    [APIID] uniqueidentifier  NOT NULL,
    [APIUrl] varchar(50)  NOT NULL,
    [APIName] varchar(20)  NOT NULL
);
GO

-- Creating table 'CommentInfo'
CREATE TABLE [dbo].[CommentInfo] (
    [CommentID] int IDENTITY(1,1) NOT NULL,
    [StickID] int  NOT NULL,
    [StickContent] varchar(800)  NOT NULL,
    [UserID] uniqueidentifier  NOT NULL,
    [CommentTime] datetime  NOT NULL,
    [ParentCommentID] int  NOT NULL,
    [StickInfo_StickID] int  NOT NULL,
    [UserInfo_UserID] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'MusicInfo'
CREATE TABLE [dbo].[MusicInfo] (
    [MusicID] uniqueidentifier  NOT NULL,
    [MusicCoverUrl] varchar(50)  NOT NULL,
    [MusicName] nchar(10)  NOT NULL,
    [SingerName] nchar(15)  NOT NULL,
    [MusicDescribe] nvarchar(300)  NULL,
    [InclubdedTime] datetime  NOT NULL,
    [PlayFrequency] int  NOT NULL,
    [Class] int  NOT NULL,
    [MusciUrl] varchar(50)  NOT NULL
);
GO

-- Creating table 'NovelInfo'
CREATE TABLE [dbo].[NovelInfo] (
    [NovelID] uniqueidentifier  NOT NULL,
    [NovelCoverUrl] varchar(50)  NOT NULL,
    [NovelName] nchar(15)  NOT NULL,
    [AuthorName] nchar(10)  NOT NULL,
    [NovelDescribe] nvarchar(300)  NULL,
    [InclubdeTime] datetime  NOT NULL,
    [DownFrequency] int  NOT NULL,
    [Class] int  NOT NULL,
    [DownUrl] varchar(50)  NOT NULL,
    [OnlineUrl] varchar(50)  NOT NULL
);
GO

-- Creating table 'RecordInfo'
CREATE TABLE [dbo].[RecordInfo] (
    [RecordGuID] uniqueidentifier  NOT NULL,
    [UserID] uniqueidentifier  NOT NULL,
    [VideoTitle] varchar(50)  NULL,
    [VideoUrl] varchar(50)  NULL,
    [MusicTitle] varchar(50)  NULL,
    [MusicUrl] varchar(50)  NULL,
    [NovelTitle] varchar(50)  NULL,
    [AppTitle] varchar(50)  NULL,
    [AppUrl] varchar(50)  NULL,
    [SitckTitle] varchar(50)  NULL,
    [SitckUrl] varchar(50)  NULL,
    [UserInfo_UserID] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'RoleInfo'
CREATE TABLE [dbo].[RoleInfo] (
    [RoleID] int IDENTITY(1,1) NOT NULL,
    [RoleName] varchar(50)  NOT NULL,
    [U] bit  NOT NULL,
    [S] bit  NOT NULL,
    [D] bit  NOT NULL,
    [A] bit  NOT NULL,
    [UserInfo_UserID] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'StickInfo'
CREATE TABLE [dbo].[StickInfo] (
    [StickID] int IDENTITY(1,1) NOT NULL,
    [UserID] uniqueidentifier  NOT NULL,
    [StickName] nvarchar(50)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [ReplyTime] datetime  NULL,
    [BrowssFrequency] int  NULL,
    [CreamState] bit  NOT NULL,
    [ExperienceValue] int  NOT NULL
);
GO

-- Creating table 'UserInfo'
CREATE TABLE [dbo].[UserInfo] (
    [UserID] uniqueidentifier  NOT NULL,
    [UserName] nvarchar(20)  NOT NULL,
    [PassWord] varchar(50)  NOT NULL,
    [UserIcon] varchar(60)  NULL,
    [LoginFrequency] int  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [LastLoginTime] datetime  NOT NULL,
    [LoginIP] varchar(20)  NOT NULL,
    [LoginCity] varchar(50)  NOT NULL,
    [QQ] int  NULL,
    [PNumber] int  NULL,
    [WeiXin] varchar(20)  NULL,
    [RoleId] int  NOT NULL,
    [RoleArea] varchar(20)  NOT NULL,
    [UserLevel] int  NOT NULL,
    [Experience] int  NOT NULL,
    [UserState] bit  NOT NULL
);
GO

-- Creating table 'VideoInfo'
CREATE TABLE [dbo].[VideoInfo] (
    [VideoID] int IDENTITY(1,1) NOT NULL,
    [VideoCoverUrl] varchar(50)  NOT NULL,
    [VideoName] nvarchar(10)  NOT NULL,
    [StarName] nvarchar(15)  NULL,
    [VideoDescribe] nvarchar(300)  NULL,
    [InclubdedTime] datetime  NOT NULL,
    [UpdateTime] datetime  NULL,
    [PlayFrequency] int  NOT NULL,
    [Class] int  NOT NULL
);
GO

-- Creating table 'VideoRecordInfo'
CREATE TABLE [dbo].[VideoRecordInfo] (
    [RecordID] uniqueidentifier  NOT NULL,
    [VideoID] int  NOT NULL,
    [VideoDrama] int  NOT NULL,
    [ViderUrl] varchar(50)  NOT NULL,
    [VideoRecordInfoVideoInfo_VideoRecordInfo_VideoID] int  NOT NULL
);
GO

-- Creating table 'AppInfo'
CREATE TABLE [dbo].[AppInfo] (
    [AppID] uniqueidentifier  NOT NULL,
    [AppIconUrl] varchar(50)  NOT NULL,
    [AppName] nvarchar(15)  NOT NULL,
    [AppDescribe] nvarchar(300)  NULL,
    [Class] int  NOT NULL,
    [DownUrl] varchar(50)  NOT NULL,
    [DownFrequency] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [APIID] in table 'APIInfo'
ALTER TABLE [dbo].[APIInfo]
ADD CONSTRAINT [PK_APIInfo]
    PRIMARY KEY CLUSTERED ([APIID] ASC);
GO

-- Creating primary key on [CommentID] in table 'CommentInfo'
ALTER TABLE [dbo].[CommentInfo]
ADD CONSTRAINT [PK_CommentInfo]
    PRIMARY KEY CLUSTERED ([CommentID] ASC);
GO

-- Creating primary key on [MusicID] in table 'MusicInfo'
ALTER TABLE [dbo].[MusicInfo]
ADD CONSTRAINT [PK_MusicInfo]
    PRIMARY KEY CLUSTERED ([MusicID] ASC);
GO

-- Creating primary key on [NovelID] in table 'NovelInfo'
ALTER TABLE [dbo].[NovelInfo]
ADD CONSTRAINT [PK_NovelInfo]
    PRIMARY KEY CLUSTERED ([NovelID] ASC);
GO

-- Creating primary key on [RecordGuID] in table 'RecordInfo'
ALTER TABLE [dbo].[RecordInfo]
ADD CONSTRAINT [PK_RecordInfo]
    PRIMARY KEY CLUSTERED ([RecordGuID] ASC);
GO

-- Creating primary key on [RoleID] in table 'RoleInfo'
ALTER TABLE [dbo].[RoleInfo]
ADD CONSTRAINT [PK_RoleInfo]
    PRIMARY KEY CLUSTERED ([RoleID] ASC);
GO

-- Creating primary key on [StickID] in table 'StickInfo'
ALTER TABLE [dbo].[StickInfo]
ADD CONSTRAINT [PK_StickInfo]
    PRIMARY KEY CLUSTERED ([StickID] ASC);
GO

-- Creating primary key on [UserID] in table 'UserInfo'
ALTER TABLE [dbo].[UserInfo]
ADD CONSTRAINT [PK_UserInfo]
    PRIMARY KEY CLUSTERED ([UserID] ASC);
GO

-- Creating primary key on [VideoID] in table 'VideoInfo'
ALTER TABLE [dbo].[VideoInfo]
ADD CONSTRAINT [PK_VideoInfo]
    PRIMARY KEY CLUSTERED ([VideoID] ASC);
GO

-- Creating primary key on [RecordID] in table 'VideoRecordInfo'
ALTER TABLE [dbo].[VideoRecordInfo]
ADD CONSTRAINT [PK_VideoRecordInfo]
    PRIMARY KEY CLUSTERED ([RecordID] ASC);
GO

-- Creating primary key on [AppID] in table 'AppInfo'
ALTER TABLE [dbo].[AppInfo]
ADD CONSTRAINT [PK_AppInfo]
    PRIMARY KEY CLUSTERED ([AppID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [StickInfo_StickID] in table 'CommentInfo'
ALTER TABLE [dbo].[CommentInfo]
ADD CONSTRAINT [FK_CommentInfoStickInfo]
    FOREIGN KEY ([StickInfo_StickID])
    REFERENCES [dbo].[StickInfo]
        ([StickID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CommentInfoStickInfo'
CREATE INDEX [IX_FK_CommentInfoStickInfo]
ON [dbo].[CommentInfo]
    ([StickInfo_StickID]);
GO

-- Creating foreign key on [UserInfo_UserID] in table 'CommentInfo'
ALTER TABLE [dbo].[CommentInfo]
ADD CONSTRAINT [FK_CommentInfoUserInfo]
    FOREIGN KEY ([UserInfo_UserID])
    REFERENCES [dbo].[UserInfo]
        ([UserID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CommentInfoUserInfo'
CREATE INDEX [IX_FK_CommentInfoUserInfo]
ON [dbo].[CommentInfo]
    ([UserInfo_UserID]);
GO

-- Creating foreign key on [UserInfo_UserID] in table 'RoleInfo'
ALTER TABLE [dbo].[RoleInfo]
ADD CONSTRAINT [FK_RoleInfoUserInfo]
    FOREIGN KEY ([UserInfo_UserID])
    REFERENCES [dbo].[UserInfo]
        ([UserID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RoleInfoUserInfo'
CREATE INDEX [IX_FK_RoleInfoUserInfo]
ON [dbo].[RoleInfo]
    ([UserInfo_UserID]);
GO

-- Creating foreign key on [VideoRecordInfoVideoInfo_VideoRecordInfo_VideoID] in table 'VideoRecordInfo'
ALTER TABLE [dbo].[VideoRecordInfo]
ADD CONSTRAINT [FK_VideoRecordInfoVideoInfo]
    FOREIGN KEY ([VideoRecordInfoVideoInfo_VideoRecordInfo_VideoID])
    REFERENCES [dbo].[VideoInfo]
        ([VideoID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VideoRecordInfoVideoInfo'
CREATE INDEX [IX_FK_VideoRecordInfoVideoInfo]
ON [dbo].[VideoRecordInfo]
    ([VideoRecordInfoVideoInfo_VideoRecordInfo_VideoID]);
GO

-- Creating foreign key on [UserInfo_UserID] in table 'RecordInfo'
ALTER TABLE [dbo].[RecordInfo]
ADD CONSTRAINT [FK_RecordInfoUserInfo]
    FOREIGN KEY ([UserInfo_UserID])
    REFERENCES [dbo].[UserInfo]
        ([UserID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RecordInfoUserInfo'
CREATE INDEX [IX_FK_RecordInfoUserInfo]
ON [dbo].[RecordInfo]
    ([UserInfo_UserID]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------